<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh">
<head>

	<jsp:include page="/commonPages/admin-meta.jsp" flush="true" />
	<!-- CSS files -->
	<jsp:include page="/commonPages/admin-style.jsp" flush="true" />
	<style type="text/css">
	.glyphicon{
		width: 20px;
		height: 20px;
		cursor: pointer;
	}
	.checkbox{
		margin-top: 10px!important;
	}
	 #map{
                position: relative;
                height: 520px;
                border:1px solid #3473b7;
            }
            #toolbar{
                position: relative;
                height: 33px;
                padding-top:5;
            }
            
            body{
                margin: 0;
                overflow: hidden;
                background: #fff;
            }
            
	</style>
	<script src="./libs/SuperMap.Include.js"></script>
    <script type="text/javascript">
    var map, local, layer, vectorLayer,
    style = {
        strokeColor: "#304DBE",
        strokeWidth: 1,
        fillColor: "#304DBE",
        fillOpacity: "0.8"
    },
    url = "http://222.25.188.1:50118/iserver/services/map-YC/rest/maps/urban_master_plan";
    
    function init(){
        map = new SuperMap.Map("map",{controls: [
            new SuperMap.Control.LayerSwitcher(),
            new SuperMap.Control.ScaleLine(),
            new SuperMap.Control.Zoom(),
            new SuperMap.Control.Navigation({
                dragPanOptions: {
                    enableKinetic: true
                }
            })]
        });
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {transparent: true, cacheEnabled: true}, {maxResolution:"auto"});
        layer.events.on({"layerInitialized":addLayer});
        vectorLayer = new SuperMap.Layer.Vector("Vector Layer");
    }

    function addLayer() {
        map.addLayers([layer, vectorLayer]);
        map.setCenter(new SuperMap.LonLat(37426892.09 , 4083177.09), 0);
    }
    function queryBySQL() {
        vectorLayer.removeAllFeatures();

        var queryParam, queryBySQLParams, queryBySQLService;
        if(document.getElementById("se").value){ 
        	queryParam = new SuperMap.REST.FilterParameter({
            name: "县城城市总体规划@超图数据.1",
            attributeFilter: "SmID = "+document.getElementById("se").value
        });}
        else{
        	alert("查询的Id不存在 ");
        }
       
        queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
            queryParams: [queryParam]
        });
        queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
            eventListeners: {"processCompleted": processCompleted, "processFailed": processFailed}});
        queryBySQLService.processAsync(queryBySQLParams);
    }
    function processCompleted(queryEventArgs) {
        var i, j, feature,
                result = queryEventArgs.result;
        if (result && result.recordsets) {
            for (i=0; i<result.recordsets.length; i++) {
                if (result.recordsets[i].features) {
                    for (j=0; j<result.recordsets[i].features.length; j++) {
                        feature = result.recordsets[i].features[j];
                        feature.style = style;
                        vectorLayer.addFeatures(feature);
                    }
                }
            }
        }
    }
    function processFailed(e) {
        
    }
    function clearFeatures() {
        //先清除上次的显示结果
        vectorLayer.removeAllFeatures();
        vectorLayer.refresh();
    }
    </script>
</head>
<body onload="init()">
	<div id="wrapper">

        <!-- Navigation -->
        <jsp:include page="/commonPages/admin-navigator.jsp" flush="true" />

        <!-- Page Content -->
        <div id="page-wrapper">
        <div id="toolbar">
        	<input type = "text" text = "请输入要查询的ID:" id = "se"/>
            <input type="button" value="查询" onclick="queryBySQL()" />
            <input type="button" value="清除" onclick="clearFeatures()" />
        </div>
            <div id="map"></div>
            
            
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->
	
	<!-- JS files -->
    <jsp:include page="/commonPages/admin-script.jsp" flush="true" />
</body>
</html>
  <% String url =request.getParameter("MapUrl");%>